package com.usian.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.article.mapper.ApAuthorMapper;
import com.usian.article.service.ApAuthorService;
import com.usian.model.article.pojos.ApAuthor;
import org.springframework.stereotype.Service;

@Service
public class ApAuthorServiceImpl extends ServiceImpl<ApAuthorMapper, ApAuthor> implements ApAuthorService {

    @Override
    public ApAuthor findByUserId(Integer userId) {
        if(userId!=null){
            QueryWrapper<ApAuthor> queryWrapper =new QueryWrapper<>();
            queryWrapper.lambda().eq(ApAuthor::getUserId,userId);

            ApAuthor apAuthor = this.getOne(queryWrapper);

            return apAuthor;
        }
        return null;
    }

    @Override
    public boolean saveAuthor(ApAuthor apAuthor) {
        return this.save(apAuthor);
    }
}
